#include "wx_pch.h"
#include "PlotWindow.h"

#ifndef WX_PRECOMP
	//(*InternalHeadersPCH(PlotWindow)
	#include <wx/intl.h>
	#include <wx/string.h>
	//*)
#endif
//(*InternalHeaders(PlotWindow)
//*)

//(*IdInit(PlotWindow)
const long PlotWindow::ID_CUSTOM1 = wxNewId();
//*)

BEGIN_EVENT_TABLE(PlotWindow,wxDialog)
	//(*EventTable(PlotWindow)
	//*)
END_EVENT_TABLE()

MyPlot::MyPlot(superBot *theSBot) {
  sBot = theSBot;
  //SetName(sBot->name);

  wxImage *myImage = new wxImage(_("./images/greendot.gif"));
  myImage->RotateHue(sBot->hue);
  wxBitmap myBitmap(*myImage);
  wxPen myPen(myBitmap, 1);

  maxi = sBot->numbers.size();
  mini = sBot->startTic;

  SetPen(myPen);
}

double MyPlot::GetY( double x ) {
  //double between = x - floor(x);
  if(x >=0 && x < sBot->numbers.size()) {
    return (double)sBot->numbers[(int)x];
    //return (sBot->numbers[(int)floor(x)])* (1.0 - between) + (sBot->numbers[(int)ceil(x)]) * (between);
  } else {
    return 0;
  }
}

double MyPlot::GetMinX() {
  return 0;
}

double MyPlot::GetMaxX() {
  return sBot->numbers.size();
}

PlotWindow::PlotWindow(wxWindow* parent,wxWindowID id,const wxPoint& pos,const wxSize& size)
{
	//(*Initialize(PlotWindow)
	wxBoxSizer* BoxSizer1;

	Create(parent, id, _("Plot"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxCLOSE_BOX|wxMAXIMIZE_BOX|wxMINIMIZE_BOX, _T("id"));
	SetClientSize(wxSize(400,400));
	Move(wxDefaultPosition);
	SetMinSize(wxSize(400,400));
	BoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
	thePlot = new mpWindow(this, -1, wxPoint(0,0), wxSize(100,100), wxSUNKEN_BORDER);
	BoxSizer1->Add(thePlot, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	SetSizer(BoxSizer1);
	BoxSizer1->SetSizeHints(this);
	Center();
	//*)

	thePlot->AddLayer(new mpScaleX(wxT("Tics"), mpALIGN_BOTTOM, true));
	thePlot->AddLayer(new mpScaleY(wxT("Number of bots"), mpALIGN_LEFT, true));
}

PlotWindow::~PlotWindow()
{
	//(*Destroy(PlotWindow)
	//*)
}

